package com.anlu.base;

import java.util.concurrent.ExecutionException;

public interface AsyncResult <T> {

    /**
     * 是否完成
     * @return
     */
    boolean isCompleted();
    /**
     * Gets the value of completed async task.
     *
     * @return evaluated value or throws ExecutionException if execution has failed
     * @throws ExecutionException    if execution has failed, containing the root cause
     * @throws IllegalStateException if execution is not completed
     */
    T getValue()throws ExecutionException;

    /**
     * Blocks the current thread until the async task is completed.
     *
     * @throws InterruptedException if the execution is interrupted
     */
    void await() throws InterruptedException;

}
